{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% import "macro_functions.phtml" as mf %}
{% block meta_title %}System activity{% endblock %}
{% set active_menu = 'activity' %}

{% block content %}
<div class="widget">
    <div class="head"><h5 class="iFrames">{% trans 'System activity' %}</h5></div>

{{ mf.table_search }}
<table class="tableStatic wide">
    <thead>
        <tr>
            <td style="width: 2%"><input type="checkbox" class="batch-delete-master-checkbox"/></td>
            <td colspan="2">{% trans 'Message' %}</td>
            <td>{% trans 'Ip' %}</td>
            <td>{% trans 'Country' %}</td>
            <td>{% trans 'Date' %}</td>
            <td style="width: 5%">&nbsp;</td>
        </tr>
    </thead>

    <tbody>
    {% set events = admin.activity_log_get_list({"per_page":30, "page":request.page}|merge(request)) %}
    {% for i, event in events.list %}
    <tr>
        <td><input type="checkbox" class="batch-delete-checkbox" data-item-id="{{ event.id }}"/></td>
        <td>
            {% if event.client %}
            <a href="{{ 'client/manage'|alink }}/{{ event.client.id }}" title="{{ event.client.name }}"><img src="{{ event.client.email|gravatar }}?size=20" alt="{{ event.client.name }}" /> {{ event.client.name }} </a>
            {% elseif event.staff %}
            <a href="{{ 'staff/manage'|alink }}/{{ event.staff.id }}" title="{{ event.staff.name }}"><img src="{{ event.staff.email|gravatar }}?size=20" alt="{{ event.staff.name }}" /> {{ event.staff.name }}</a>
            {% else %}
            Guest
            {% endif %}
        </td>
        <td><div style="overflow: auto; width: 250px;">{{ event.message }}</div></td>
        <td>{{ event.ip }}</td>
        <td>{{ event.ip|ipcountryname }}</td>
        <td>{{ event.created_at|date('Y-m-d H:i') }}</td>
        <td class="actions">
            <a class="bb-button btn14 bb-rm-tr api-link" data-api-confirm="{% trans 'Are you sure?' %}" data-api-redirect="{{ 'activity'|alink }}" href="{{ 'api/admin/activity/log_delete'|link({'id' : event.id}) }}"><img src="images/icons/dark/trash.png" alt=""></a>
        </td>
    </tr>
    {% else %}
    <tr>
        <td colspan="6">
            {% trans 'The list is empty' %}
        </td>
    </tr>
    {% endfor %}
    </tbody>
</table>

</div>
{% include "partial_batch_delete.phtml" with {'action' : 'admin/activity/batch_delete'} %}
{% include "partial_pagination.phtml" with {'list': events, 'url':'activity'} %}

{% endblock %}
